# 类型转换
print("===============================整数转换================================")
a = "123"
print(type(a))
b = int(a)
print(type(b))
print(b)

# 浮点类型转成int 会丢失小数点后的数据
print("===============================浮点数转换整数================================")
c = 1.23
print(type(c))
d = int(c)
print(type(d))
print(d)

print("+++++++++++++++++++++浮点数转换+++++++++++++++++++++")
aa = 123
print(type(aa))
bb = float(aa)
print(type(bb))
print(bb)

print("+++++++++++++++++++++字符串转换+++++++++++++++++++++")
# 浮点数转成字符串末尾0 会删除, 除非是第一位小数是0保留 例如 1.0
qq = 231.12300
print(type(qq))
ww = str(qq)
print(type(ww))
print(ww)

print("+++++++++++++++++++++执行转换函数+++++++++++++++++++++")
print("数字字符串相加并返回结果:%d" % eval("10+10"))
# 不支持数字和字符串相加
# print(eval("10+'10'"))

# eval() 支持 list set dict tuple 和字符串之间的转换,就是把字符串的引号去掉了


print("+++++++++++++++++++++将可迭代对象转换成列表+++++++++++++++++++++")
# 将每个元素用逗号分割
print("字符串转集合:", list("1234"))
print("元组转集合:", list(("1234", "678")))
print("字典转集合,只保存键,值丢弃:", list({"a": "啊", "b": "qw"}))
print("集合转集合", list({"aa", "bb", "cc", "aa"}))

# 拼接两个元组转换成列表
z = zip(("a", "b", "c"), ("1", "2", "3"))
l = list(z)
print("拼接两个元组转换成列表:%s" % l)
